package lib.gui;

import lib.BitmapButtonField;
import lib.classes.TitleBar;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class Page extends ScreenTemplate implements FieldChangeListener
{

	BitmapButtonField left;
	BitmapButtonField right;
	VerticalFieldManager contentPane;
	public Page(String title) 
	{
		super("", true);
		this.left =  new BitmapButtonField(Bitmap.getBitmapResource("img/back2.png"));
		left.setChangeListener(this);
		this.right = new BitmapButtonField(Bitmap.getBitmapResource("img/settings2.png"));
		right.setChangeListener(this);
		contentPane = new VerticalFieldManager(USE_ALL_WIDTH);
		TitleBar bar = new TitleBar(left, title, right);
		updateTitle(bar);
		
		super.add(contentPane);
	}
	
	public void add(Field f)
	{
		contentPane.add(f);
	}

	public void fieldChanged(Field field, int context) 
	{
		if(field == this.left)
		{
			popScreen();
		}else if(field == this.right)
		{
			pushScreen(new SettingsScreen());
		}
	}
	
	public void deleteAll()
	{
		contentPane.deleteAll();
	}
}
